package neuralmusic.brain.module;

import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;

public abstract class Scheduler {

	// Thread fireThread;

	private boolean running = false;
	
	public abstract double getCurrentTimeInSecs();

	public abstract BasicDelayed take() throws InterruptedException;

	public abstract void add(BasicDelayed neuron);

	public abstract long getDelay(TimeUnit unit, double trigger);

	public abstract int size();

	public void start() {
		running = true;
		while (running) {
			BasicDelayed n;
			try {
				n = take();
				n.fire();
			} catch (InterruptedException ex) {
				Logger.getLogger(Brain.class.getName()).log(Level.SEVERE, null,
						ex);
			} catch (BrainException e) {

				e.printStackTrace();
			}
		}
	}
	
	public void stop() {
		running = false;
	}

}
